package cn.com.jcoo.api.admin;

import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "后台管理：登录模块")
@RestController
public class SignApi {

    @Operation(summary = "登录")
    @PostMapping("/login")
    public String login() {
        StpUtil.login("1231");
        SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
        return tokenInfo.getTokenValue();
    }


    @Operation(summary = "登出")
    @PostMapping("/logout")
    public void logout() {
        StpUtil.logout("1231");
    }


    @Operation(summary = "用户信息")
    @PostMapping("/loginUser")
    public SaTokenInfo loginUser() {
        return StpUtil.getTokenInfo();
    }
}
